package edu.ccut.saturn.workflow.common;

import edu.ccut.saturn.component.ComponentFactory;
import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.workflow.model.WorkFlowInfo;

public class GetWorkFlowDefine extends DefaultComponent {
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		String process_define_id = (String) parameterContext.getParameterValue(0);
		WorkFlowInfo workflowInfo = null;
		workflowInfo = WorkFlowDefineManager.getWorkFlowDefine(process_define_id);
		if(workflowInfo==null){
			IParameterContext pc = ComponentFactory.createParameterContext();
			pc.addParameter(process_define_id, String.class);
			pc.addParameter(null, Object.class);
			executeLogicSupportsTransaction(parameterContext, pc, Constants.GET_WORKFLOW_CONTENT_LOGIC);
			workflowInfo = (WorkFlowInfo)pc.getParameterValue(1);
			WorkFlowDefineManager.setWorkFlowDefine(process_define_id, workflowInfo);
		}
		parameterContext.setParameter(1,workflowInfo );
	}
}